#ifndef NGTABLE_H
#define NGTABLE_H

#include "ngcard.h"
#include <string>
#include <vector>
#include <unordered_map>
#include <qstring.h>
#include <yaml-cpp/yaml.h>

struct NGReason {
    int code;
    std::string reason;
};

struct NGCombination {
    int code;
    std::vector<int> reasons;
    std::string description;
};

class NGTable {
public:
    static  NGTable &getInstance();

    NGReason getNGReason(int code) const;
    NGCombination getNGCombination(int code) const;
    std::string getNGDescription(int code) const;
    std::vector<NGCombination> getCombinations() const;

    void mergeDefects(NgCard& target, const NgCard& source) const;

    QString parseNGListToDescription(const std::vector<int> &ngList);
private:
    NGTable(const std::string& configFilePath = "master/config/ng_reasons.yaml");
    NGTable& operator=(const NGTable& rhs) = delete;
    void loadConfig(const std::string& configFilePath);

    std::unordered_map<int, NGReason> ngReasons_;
    std::unordered_map<int, NGCombination> ngCombinations_;
};
void testNgTable();
#endif // NGTABLE_H
